# -*- conding:UTF-8 -*-

'''
@ Project: news
@ File: create_app.py
@ Author: 韩成瑾
@ Date：2022/7/28 9:13

'''

from flask import Flask
from flask_cors import CORS
from apps.teacher import teacher_bp
from apps.course import course_bp
from apps.student import student_bp
from models.model import db


def create_app(config):
    flask_app = Flask(__name__)

    # 挂载配置文件
    flask_app.config.from_object(config)

    # 跨域
    # cors = CORS(flask_app)

    # 初始化模型
    db.init_app(flask_app)

    # 注册蓝图
    flask_app.register_blueprint(teacher_bp)
    flask_app.register_blueprint(student_bp)
    flask_app.register_blueprint(course_bp)

    return flask_app